﻿using AntdUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CKS.MES.Server.UserControls
{
    public class OeeTable:AntdUI.Table
    {

       

        public OeeTable() { 
            this.VisibleHeader = false;
            BindColumns();
        }

        public List<OeeModel> oees = new List<OeeModel>();

        private void BindColumns()
        {
            this.EditMode = TEditMode.None;
            this.Columns = new ColumnCollection();
            this.Columns.Add(new Column("ItemName", "名称"));
            this.Columns.Add(new Column("ItemDesc", "描述"));

            //this.SetStyle(ControlStyles.Selectable,false);
            RowSelectedBg = Color.Transparent;
            RowHoverBg = Color.Transparent;
            Config.Animation = false;
            //OEE设备综合效率
            BorderColor = Color.Transparent;
            Color NameColor = Color.WhiteSmoke; //ColorTranslator.FromHtml("#2FA3E2");
            Color DefaultForce = ColorTranslator.FromHtml("#AEE3FF");
            //故障时间 停机时间 设备稼动率
            oees.Add(new OeeModel() { ItemName = new CellText("运行总时间") { Fore = NameColor }  ,ItemDesc = new CellText("00:00:00") { Fore = DefaultForce } });
            oees.Add(new OeeModel() { ItemName = new CellText("故障时间") { Fore = NameColor }, ItemDesc = new CellText("00:00:00") { Fore = Color.Red}  });
            oees.Add(new OeeModel() { ItemName = new CellText("停机时间") { Fore = NameColor }, ItemDesc = new CellText("00:00:00") { Fore = Color.Red} });
            //‌稼动率‌：实际运行时间除以可用时间，再乘以100%，得到稼动率的百分比。例如，6小时实际运行时间和8小时可用时间的稼动率为75%
            oees.Add(new OeeModel() { ItemName = new CellText("设备稼动率") { Fore = NameColor }, ItemDesc = new CellText("99.99%") { Fore = DefaultForce } });
            this.DataSource = oees;

            
            
        }


        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            base.OnPaintBackground(pevent);
        }


        public class OeeModel:AntdUI.NotifyProperty
        {
            private CellText _itemName;
            private CellText _itemDesc;
            /// <summary>
            /// 项，eg:运行总时间
            /// </summary>
            public CellText ItemName
            {
                get { return _itemName; }
                set
                {
                    _itemName = value;
                    OnPropertyChanged("ItemName");
                }
            }
            /// <summary>
            /// 描述信息 ，如 : 10分钟
            /// </summary>
            public CellText ItemDesc
            {
                get { return _itemDesc; }
                set
                {
                    _itemDesc = value;
                    OnPropertyChanged("ItemDesc");
                }
            }
        }
    }
}
